<?php
function article_get($id= 0, $is_no_cache = 0){
    return is_array($id) ? $id : cache_get_table_obj('article', $id, $is_no_cache);
}
function article_img($article_id, $limit=''){
    $img = db_get_list('wx_img', array('article_id' => $article_id, 'tid' => 1, 'is_show' => 1, 'state' => 1), $limit);
    return $img;
}
function article_update($article, $up_data){
    db_update('article', $up_data, array('id' => $article['id']));
    article_get($article['id'], 1);
}
function article_view_update($article_id, $view){
    db_update('article', ['view' => ($view+1)], ['id' => $article_id]);
    article_get($article_id, 1);
}
function article_view($user, $article){
    $r = db_get_obj('view', ['article_id' => $article['id'], 'uid' => $user['id']]);
    if (! $r) {
        db_insert('view', ['uid' => $user['id'], 'article_id' => $article['id'], 'article_uid' => $article['uid'], 'ctime' => time()]);
    }
}
function token_user_get($id= 0, $is_no_cache = 0){
    return is_array($id) ? $id : cache_get_table_obj('article_user', $id, $is_no_cache);
}
function token_user_get_tk($tk){
    return db_get_obj('article_user', ['tk' => $tk]);
}
